<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<script src="js/jquery.min.js"></script>
		<title>多选</title>
		<style type="text/css">
			input{
				margin-left: 50px;
				margin-top: 50px;
			}
			button{
				margin-top: 30px;
				margin-left: 80px;
			}
			body{
				background-color: #5F9EA0;
			}
		</style>
	</head>
	<body>
		<div id="">
			<input type="checkbox" id="hobby"/>唱歌
			<input type="checkbox" id="hobby"/>跳舞
			<input type="checkbox" id="hobby"/>下棋
			<input type="checkbox" id="hobby"/>游泳
		</div>
		<div id="">
			<button id="selectall" type="button">全选</button>
			<button id="selectnone" type="button">全不选</button>
			<button id="selectoppo" type="button">反选</button>
		</div>
	</body>
	
	<script type="text/javascript">
		$("#selectall").click(function(){
			$("#hobby").each(function(){
				$("input[id='hobby']").prop("checked",true);
			})
		});
		$("#selectnone").click(function(){
			$("#hobby").each(function(){
				$("input[id='hobby']").attr("checked",false);
			})
		});
		$("#selectoppo").click(function(){
			
		})
	</script>
</html>
